class Solution:
    def minSteps(self, n: int) -> int:
        inf = float('inf')
        dp = [[inf for _ in range(n + 1)] for _ in range(n + 1)]
        dp[1][0] = 0
        dp[1][1] = 1
        for i in range(2, n + 1):
            for j in range(n + 1):
                if i >= j:
                    dp[i][j] = min(dp[i][j], dp[i - j][j] + 1)
            dp[i][i] = min(dp[i][i], min(dp[i]) + 1)
        return min(dp[-1])


if __name__ == '__main__':
    s = Solution()
    r = s.minSteps(6)
    print(r)
